Skip to content

fix: include stdout diagnostics when stderr is empty on swift package failure#255

Merged
cameroncooke merged 1 commit intogetsentry:mainfrom
doovers:fix/swift-package-swallow-diagnostics
Mar 2, 2026
Merged

fix: include stdout diagnostics when stderr is empty on swift package failure#255
cameroncooke merged 1 commit intogetsentry:mainfrom
doovers:fix/swift-package-swallow-diagnostics

Conversation

@doovers
Copy link
Contributor

@doovers doovers commented Mar 1, 2026

Summary

  • Fixes swift_package_build, swift_package_test, and swift_package_clean swallowing compiler diagnostics on failure
  • SPM writes compiler diagnostics to stdout, not stderr — the ?? operator does not treat "" as falsy, so when stderr is empty the stdout diagnostics were silently dropped
  • Switching to || fixes the fallback so diagnostics are always included in the error response

Changes

  • swift_package_build.ts, swift_package_test.ts, swift_package_clean.ts: result.error ?? result.outputresult.error || result.output
  • Added regression tests for the empty-stderr case in swift_package_build and swift_package_test

Test plan

  • Unit tests pass: npx vitest run src/mcp/tools/swift-package/__tests__/swift_package_build.test.ts src/mcp/tools/swift-package/__tests__/swift_package_test.test.ts
  • CLI test: create a Swift package with let broken: DOESNOTEXIST = 42, run node build/cli.js swift-package build --package-path <path> — full diagnostics with file/line/col now appear in the error response

Fixes #243

… failure

SPM writes compiler diagnostics to stdout, not stderr. The ?? operator
does not treat empty string as falsy, so when stderr is "" the diagnostics
in stdout were never included in the error response. Switching to ||
fixes the fallback for all three affected tools.

Fixes getsentry#243
@cameroncooke
Copy link
Collaborator

@doovers Thanks for the contribution and good catch!

@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 2, 2026

Open in StackBlitz

npm i https://pkg.pr.new/xcodebuildmcp@255

commit: a9aef9b

@cameroncooke cameroncooke merged commit 5c091c6 into getsentry:main Mar 2, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] swift_package_build/test swallow compiler diagnostics on failure

2 participants